<link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all" rel="stylesheet" type="text/css" />
<link href="{{ config('app.static_url') }}assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="{{ config('app.static_url') }}assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
<link href="{{ config('app.static_url') }}assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="{{ config('app.static_url') }}assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
<link href="{{ config('app.static_url') }}assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min.css" rel="stylesheet" type="text/css" />

<link href="{{ config('app.static_url') }}assets/global/plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
<link href="{{ config('app.static_url') }}assets/global/plugins/select2/css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" />
<from action="post">
    <br>
    基本信息  <!--a href="javascript:;" class="edit" data-target="personal_info">edit</a-->
    <hr>
    <div class="personal_info" data-data='{}'>

    <!-- {"name":"xxx", "gender":"male", "email":"477659@qq.com", "birthday":"1999-10", "mobile":"13723457688","education":2} -->

    </div>
    <br>
    求职意向 <a href="javascript:;" class="edit" data-target="job_intension">edit</a>
    <hr>
    <div class="job_intension" data-data='{}'>
    </div>
    <br>
    工作经历
    <hr>
    <table>
        <tr>
            <td>公司名称</td>
            <td><input name="expect_work_cities"></td>
        </tr>
        <tr>
            <td>担任职位</td>
            <td><input name="expect_salary"></td>
        </tr>
        <tr>
            <td>任职时间</td>
            <td><input name="expect_industries"> 到 <input name="expect_job_title"> <a href="">至今</a></td>
        </tr>
        <tr>
            <td>工作内容</td>
            <td><input name="expect_work_cities"></td>
        </tr>
        <tr>
            <td>公司行业</td>
            <td><input name="expect_salary"></td>
        </tr>
        <tr>
            <td>公司规模</td>
            <td><input name="expect_work_cities"></td>
        </tr>
        <tr>
            <td>公司描述</td>
            <td><input name="expect_salary"></td>
        </tr>
        <tr>
            <td>工作地点</td>
            <td><input name="expect_salary"></td>
        </tr>
        <tr>
            <td>所在部门</td>
            <td><input name="expect_salary"></td>
        </tr>
        <tr>
            <td>汇报对象</td>
            <td><input name="expect_salary"></td>
        </tr>
        <tr>
            <td>下属人数</td>
            <td><input name="expect_salary"></td>
        </tr>
    </table>
    <br>
    教育经历
    <hr>
    <table>
        <tr>
            <td>毕业院校</td>
            <td><input name="expect_work_cities"></td>
        </tr>
        <tr>
            <td>专业</td>
            <td><input name="expect_salary"></td>
        </tr>
        <tr>
            <td>就读时间</td>
            <td><input name="expect_industries"> 到 <input name="expect_job_title"></td>
        </tr>
        <tr>
            <td>学历</td>
            <td><input name="expect_salary"></td>
        </tr>
    </table>
    <br>
    自我描述
    <hr>
    <table>
        <tr>
            <td></td>
            <td><textarea></textarea></td>
        </tr>

    </table>
    <br>
    项目经验
    <hr>
    <table>
        <tr>
            <td></td>
            <td><textarea></textarea></td>
        </tr>

    </table>
    <br>
    培训经历以及获得证书
    <hr>
    <table>
        <tr>
            <td></td>
            <td><textarea></textarea></td>
        </tr>

    </table>
</from>

<!-- alpha div -->

<div id="maskLayer" style="display:none">

    <iframe id="maskLayer_iframe" frameBorder=0 scrolling=no style="filter:alpha(opacity=50)"></iframe>

    <div id="alphadiv" style="filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5"></div>

    <div id="drag">

        <h3 id="drag_h"></h3>

        <div id="drag_con"></div><!-- drag_con end -->

    </div>

</div><!-- maskLayer end -->

</div>

<!-- alpha div end -->

<div id="sublist" style="display:none"></div>



<input id="jobAreaID" type="hidden" name="jobAreaID" value="" />
<script src="{{ config('app.static_url') }}assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="{{ config('app.static_url') }}assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="{{ config('app.static_url') }}assets/global/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="{{ config('app.static_url') }}assets/global/plugins/jquery-validation/js/additional-methods.min.js" type="text/javascript"></script>
<script src="{{ config('app.static_url') }}assets/global/plugins/jsrender/jsrender.min.js" type="text/javascript"></script>

<script src="{{ config('app.static_url') }}assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="{{ config('app.static_url') }}assets/global/plugins/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script src="{{ config('app.static_url') }}assets/global/plugins/select2/js/select2.full.min.js" type="text/javascript"></script>
<script>
    $.views.settings.delimiters("{%", "%}");
    $.views.tags("yearmonth", function(val) {
        if($.isEmptyObject(val)) return '';

        var yearmonth = val.split('-');
        return yearmonth[0] + "年" + yearmonth[1] + '月';
    });

    $.views.tags("gender", function(val) {
        return (val == 'male') ? '男' : '女';
    });


    // 模板
    $.templates({
        personal_info: '<table><tr><td>姓名</td><td>{%:name%}</td><td>性别</td><td>{%gender gender/%}</td></tr><tr><td>邮箱</td><td>{%:email%}</td><td>出生年月</td><td>{%yearmonth birthday/%}</td></tr><tr><td>手机号码</td><td>{%:mobile%}</td><td>所在地区</td><td>深圳</td></tr><tr><td>最高学历</td><td>大专</td><td>参加工作时间</td><td>2013年5月</td></tr><tr><td>目前状态</td><td>急需好工作</td><td>婚姻情况</td><td>已婚</td></tr><tr><td>目前年薪</td><td>20W/年</td><td>目前职位</td><td>部门经理</td></tr><tr><td>目前公司</td><td>深圳市力天保利科技有限公司</td></tr></table>',
        personal_info_edit: '<table>' +
        '<tr>' +
        '   <td>姓名</td> <td><input name="name" value="{%:name%}"/></td> <td>性别</td> <td><input type="radio" name="gender" value="male" {%if gender == "male"%}checked="checked"{%/if%}/> 男 <input type="radio" name="gender" value="female" {%if gender == "female"%}checked="checked"{%/if%}/> 女</td> ' +
        '</tr>' +
        '<tr>' +
        '   <td>邮箱</td> <td><input name="email" value="{%:email%}"></td> <td>出生年月</td> <td><input class="yearmonth" name="birthday" value="{%:birthday%}"></td>' +
        '</tr>' +
        '<tr>' +
        '   <td>手机号码</td> <td><input name="mobile" value="{%:mobile%}"></td> <td>所在地区</td> <td><select name="residence"><option value="1">南山区</option><option value="2">福田区</option><option value="3">罗湖区</option><option value="4">宝安区</option><option value="5">盐田区</option><option value="6">龙岗区</option><option value="7">龙华新区</option><option value="8">光明新区</option><option value="9">坪山新区</option></select></td>' +
        '</tr>' +
        '<tr>' +
        '   <td>最高学历</td> <td><select name="education"><option value="0" {%if education == "0"%}selected="selected"{%/if%}>不限</option><option value="1" {%if education == "1"%}selected="selected"{%/if%}>大专</option><option value="2" {%if education == "2"%}selected="selected"{%/if%}>本科</option></select></td> <td>参加工作时间</td> <td><input class="yearmonth" name="beginwork_at"></td>' +
        '</tr>' +
        '<tr>' +
        '   <td>目前状态</td> <td><select name="work_status"><option value="1">急找工作</option><option value="2">找工作</option><option value="3">看机会</option><option value="4">创业去啦</option><option value="5">不换工作</option><option value="6">休息一段</option></select></td> <td>婚姻情况</td> <td><select name="marital_status"><option value="1">保密</option><option value="2">已婚</option><option value="3">未婚</option><option value="4">离异</option></select></td>' +
        '</tr>' +
        '<tr>' +
        '   <td>目前年薪</td> <td><input name="yearly_salary">元/年</td> <td>目前职位</td> <td><input name="current_job_title"></td>' +
        '</tr>' +
        '<tr>' +
        '   <td>目前公司</td> <td><input name="current_company"/></td>' +
        '</tr>' +
        '<tr>' +
        '   <td></td> <td><a class="btn save">保存</a> <a class="btn cancel">取消</a></td>' +
        '</tr>' +
        '</table>',
        job_intension_edit: '<table> \
                                <tr> \
                                    <td>期望城市</td> \
                                    <td><select name="expect_work_cities" class="form-control select2-multiple" multiple><option value="1">南山区</option><option value="2">福田区</option><option value="3">罗湖区</option><option value="4">宝安区</option><option value="5">盐田区</option><option value="6">龙岗区</option><option value="7">龙华新区</option><option value="8">光明新区</option><option value="9">坪山新区</option></select></td> \
                                    <td>期望月薪</td> \
                                    <td><input name="expect_salary">/月</td> \
                                </tr> \
                                <tr> \
                                    <td>期望行业</td> \
                                    <td><select name="expect_industries" class="form-control select2-multiple" multiple><option value="1">IT互联网</option><option value="2">房地产</option><option value="3">金融</option><option value="4">快消</option><option value="5">零售</option><option value="6">制造</option><option value="7">广告传媒</option><option value="8">能源</option><option value="9">医药</option><option value="10">汽车</option><option value="11">服务业</option><option value="12">其他</option></select></td> \
                                    <td>期望职位</td> \
                                    <td><input name="expect_job_title"></td> \
                                </tr>\
                            </table>'
    });


    function init_talent_from() {
        $(".yearmonth").datepicker({
                format: "yyyy-mm",
                startView: 2,
                minViewMode: 1,
                language: "zh-CN",
                keyboardNavigation: false,
                autoclose: true
            });

        // alert(111);
    }


    $(function() {
        // personal_info();

        $(".form_datetime").datepicker({
            format: "yyyy年mm月",
            startView: 2,
            minViewMode: 1,
            language: "zh-CN",
            keyboardNavigation: false,
            autoclose: true
        });

        



        personal_info_edit();
        job_intension_edit();

        $(".select2-multiple").select2();
        $('input[name="residence"]').click(function() {
            residencySelect();
            // alert(1);
        });

        $('.personal_info').bind("DOMSubtreeModified",function(){
            init_talent_from
        });

        $('.job_intension').bind("DOMSubtreeModified",function(){

        });

        $('.edit').click(function() {
            var target = $(this).data('target');
            eval(target + '_edit()');
        });

        $(document).on('click','.cancel', function() {
            personal_info();
        });

        $(document).on('click','.save', function() {
            var name = $('.personal_info').find('[name="name"]').val();
            var gender = $('.personal_info').find('[name="gender"]:checked').val();
            var email = $('.personal_info').find('[name="email"]').val();
            var birthday = $('.personal_info').find('[name="birthday"]').val();
            var mobile = $('.personal_info').find('[name="mobile"]').val();

            var json = {name:name, gender:gender, email:email, birthday:birthday, mobile:mobile};

//            console.log(json);

            $('.personal_info').attr('data-data', JSON.stringify(json));

            personal_info();
        });

        $(document).on('click', '[name="residence"]', function(){

        });


        $(document).on('click','.city', function() {
            // var dragHtml ='<div id="jobAreaAlpha">';        //地区
            // dragHtml+='     <dl id="jobAreSelected"><dt>已选地点：</dt><dd></dd></dl>';
            // dragHtml+='     <div id="maincity2"></div>';//主要城市
            // dragHtml+='     <div id="allProv2"></div>'; //所有省市
            // dragHtml+='</div>';
            // $('#drag_h').html('<b>请选择地区（您最多能选择5项）</b><span onclick="jobArea.confirm()">确定</span>');
            // $('#drag_con').html(dragHtml);

            // jobArea.Show();
            // boxAlpha();
            // draglayer();
        });
    });

    function personal_info() {
        var info = $('.personal_info').attr('data-data');
        info = jQuery.parseJSON(info);

        // console.log(info);

        $('.personal_info').html($.templates.personal_info(info));
    }

    function personal_info_edit() {
        var info = $('.personal_info').attr('data-data');
        info = jQuery.parseJSON(info);
        

        $('.personal_info').html($.templates.personal_info_edit(info));

        init_talent_from();
    }

    function job_intension_edit() {
        var info = $('.job_intension').attr('data-data');
        info = jQuery.parseJSON(info);

        $('.job_intension').html($.templates.job_intension_edit(info));
    }

    function in_array(needle, haystack) {
        if(typeof needle == 'string' || typeof needle == 'number') {
            for(var i in haystack) {
                if(haystack[i] == needle) {
                    return true;
                }
            }
        }

        return false;
    }





</script>